package com.woniu.market_stall_web.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.market_stall_web.entity.Stall;
import com.woniu.market_stall_web.service.AuctionStallService;
import com.woniu.market_stall_web.service.StallService;
import com.woniu.market_stall_web.vo.AuctionStallVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("index")
public class MainController {
    @Autowired
    AuctionStallService auctionStallService;
    @Autowired
    StallService stallService;


    @RequestMapping("/main")
    public String index(Map map){

        List<AuctionStallVo> auctionStallVos = auctionStallService.selectAuctioning();
        for (AuctionStallVo auctionStallVo : auctionStallVos) {
            System.out.println(auctionStallVo.getStallName());
        }
        int now=1;
        int size=8;
        PageInfo<Stall> pageInfo = stallService.showRecommend(now, size);
        PageInfo<Stall> rentInfo = stallService.showAllRent(now, size);
        map.put("pageInfo", pageInfo);
        map.put("rentInfo", rentInfo);
        map.put("auctionStallList", auctionStallVos);
        System.out.println("==============================我被执行了=======================");

        return "index" ;
    }

    @RequestMapping("/resetPass")
    public String resetPass(){

        return "resetpassword";
    }
    @RequestMapping("/rentStall")
    public String rentStall(int sid,Map map) {
        Stall rentStall =stallService.showThisRent(sid);
        map.put("rentStall",rentStall);

        return "rentStall";
    }

}
